/**
 * @FileName Question8
 * @Description
 * @Author Sword
 * @date 2024-09-27
 **/
public class Question8 {
    public static void main(String[] args) {
        //编写程序求满足 1 +2!+3!+...+n! <= 9876 的最大整数
        int i, sum = 0;
        for (i = 1; ; i++) {
            int factorial = 1;
            for (int j = 1; j <= i; j++) {
                factorial *= j;
            }
            sum += factorial;
            if (sum >= 9876)
                break;
        }
        i = i - 1;
        System.out.println("最大整数：" + i);
    }

}
